package com.example.wx.dailyreport.controller.exceptionadvice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.LinkedHashMap;
import java.util.Map;

@ControllerAdvice
class ControllerExceptionAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Map<String, Object> handlerException(Exception e) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("status", 500);
        map.put("message", e.getMessage());
        System.out.println(e.getMessage());
        return map;
    }

}
